package com.bao.work.video.service.impl;

import com.bao.work.video.entity.Video;
import com.bao.work.video.enum1.Type;
import com.bao.work.video.service.VideoService;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

/**
 * @author baoye
 * @date 2024-08-01/18:34
 */
public class VideoServiceImpl implements VideoService {
    static {
        VIDEO_MAP.put(new Video("功夫熊",Type.动画),100);
        VIDEO_MAP.put(new Video("三叠纪公园",Type.科幻),150);
        VIDEO_MAP.put(new Video("复仇者部落",Type.科幻),190);
        VIDEO_MAP.put(new Video("失败的人",Type.动作),200);
        VIDEO_MAP.put(new Video("碗外豌",Type.警匪),50);
        VIDEO_MAP.put(new Video("变形金刚大战格斯拉王",Type.科幻),800);
    }
    @Override
    public void insertVideo() {
        System.out.println("请输入添加的电影名称");
        String name = INPUT.next();
        System.out.println("请输入添加的电影类型(1.动作 2.警匪 3.科幻 4.动画 5.战争)");
        int i=INPUT.nextInt();
        Type type=Type.values()[i-1];
        System.out.println("请输入添加的电影人气");
        Integer hot = INPUT.nextInt();

        VIDEO_MAP.put(new Video(name,type),hot);

        System.out.println("添加成功!");

    }

    @Override
    public void printVideo() {
        Set<Video> videos = VIDEO_MAP.keySet();
        for (Video video : videos) {
            System.out.println(video);
            System.out.println("人气:"+VIDEO_MAP.get(video)+"\n");
        }
    }

    @Override
    public void maxHot() {
        Integer maxH=-1;
        Video maxV=new Video();
        Set<Map.Entry<Video, Integer>> set = VIDEO_MAP.entrySet();
        for (Map.Entry<Video, Integer> entry : set) {
            if(entry.getValue()>maxH){
                maxH=entry.getValue();
                maxV= entry.getKey();
            }
        }
        System.out.println(maxV);
        System.out.println("人气:"+maxH+"\n");
    }

}
